//
//  BaseViewController.swift
//  FirstSwiftProduct
//
//  Created by 知合金服-Mini on 2017/10/31.
//  Copyright © 2017年 范泽华. All rights reserved.
//

import UIKit

class BaseViewController: UIViewController {

    var titleLabel = UILabel()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Do any additional setup after loading the view.
        self.automaticallyAdjustsScrollViewInsets = false
        self.view.backgroundColor = UIColor.white
      
        //        self.navigationController?.navigationBar.isHidden = false
        //        navigationController?.navigationBar.isHidden = false
        setUpNav()
    }
    
    func setUpNav() -> Void {
        let topView = UIView.init(frame: CGRect(x: 0, y: 0, width: Int(SCREEN_WIDTH), height: kStatus_Navigation_height))
        topView.backgroundColor = kThemeColor
        self.view.addSubview(topView)
        
        let backBtn = UIButton.init(type: UIButtonType.custom)
        backBtn.frame = CGRect(x: 20 * scaleWidth, y: 20, width: (SCREEN_WIDTH - 30) / 4, height: 42)
        backBtn.setImage(UIImage.init(named: "arrow_left_w"), for: UIControlState.normal)
        backBtn.addTarget(self, action: #selector(backAction), for: UIControlEvents.touchUpInside)
//        topView.addSubview(backBtn)
        backBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignment.left
        
        
        
        titleLabel = UILabel.init(frame: CGRect(x: (SCREEN_WIDTH - 30)/8, y: backBtn.center.y - 15 , width: SCREEN_WIDTH - (SCREEN_WIDTH - 30)/8*2, height: 30))
        titleLabel.textAlignment = NSTextAlignment.center
        titleLabel.textColor = kBlackTextColor
        titleLabel.font = UIFont.systemFont(ofSize: 18)
        topView.addSubview(titleLabel)
        
    }
    
    func backAction() -> Void {
        self.navigationController?.popViewController(animated: true)
    }

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
